﻿using UnityEngine;
using System.Collections;

namespace Lost{
	/// <summary>
	/// 密码锁，适用于按键、小黄车等
	/// </summary>
	public class PasswordLock : Lock {
		public enum MatchType
		{
			AllMatch, Contains
		};
		[SerializeField] protected string password;
		[SerializeField] protected MatchType matchType = MatchType.AllMatch;
		protected override bool CheckKey (LockKey key)
		{
			switch (matchType) {
			case MatchType.AllMatch:
				return (key.CurPassword == password);
				break;
			case MatchType.Contains:
				bool matchResult = true;
				foreach (char c in password) {
					matchResult = key.CurPassword.Contains (c.ToString ()) ? matchResult : false;
				}
				return matchResult;
				break;
			default:
				break;
			}
			return false;
		}
	}
}
